package com.zstu.lvxiang.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.zstu.lvxiang.mapper.TimeCategoryMapper;
import com.zstu.lvxiang.pojo.TimeCategory;
import com.zstu.lvxiang.service.ITimeCategoryService;
import com.zstu.lvxiang.vo.RespBean;
import com.zstu.lvxiang.vo.RespBeanEnum;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * <p>
 * 服务实现类
 * </p>
 *
 * @author Trafalgar
 * @since 2022-03-16
 */
@Service
public class TimeCategoryServiceImpl extends ServiceImpl<TimeCategoryMapper, TimeCategory> implements ITimeCategoryService {
    @Autowired
    TimeCategoryMapper timeCategoryMapper;

    @Override
    public RespBean insertCategory(TimeCategory category) {
        if (timeCategoryMapper.insert(category) > 0) {
            return RespBean.success(category.getId());
        }
        return RespBean.error(RespBeanEnum.ERROR);
    }

    @Override
    public RespBean delete(Integer id) {
        if (timeCategoryMapper.delete(id) > 0) {
            return RespBean.success();
        }
        return RespBean.error(RespBeanEnum.ERROR);
    }
}
